#include "lolevel.h"
#include "platform.h"
#include "core.h"
#include "conf.h"

static long *nrflag = (long*)0xC2E4;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) sub_FFEABF94_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,LR}\n"    
                "MOV     R4, R0\n"          
                "SUB     SP, SP, #0xC\n"    
                "BL      sub_FFEACA04\n"    
                "MVN     R1, #0\n"         
                "BL      sub_FFEBD168\n"  
                "MOV     R0, #0x8A\n"       
                "ADD     R1, SP, #4\n"      
                "MOV     R2, #4\n"          
                "BL      sub_FFC0BC94\n"    
                "TST     R0, #1\n"          
                "BEQ     loc_FFEABFD4\n"    
                "MOV     R1, #0x1D0\n"      
                "LDR     R0, =0xFFEABE18\n" 
                "ADD     R1, R1, #2\n"      
                "BL      sub_FFECA824\n"     
"loc_FFEABFD4:\n"                           
                "LDR     R3, =0xA5740\n"    
                "LDR     R2, =0xA5800\n"    
                "LDR     R0, [R3,#0x74]\n"  
                "LDRSH   R1, [R2,#0xE]\n"   
                "BL      sub_FFDEF8B0\n"    
                "MOV     R0, R4\n"          
                "BL      sub_FFEABD9C\n"    
                "BL      wait_until_remote_button_is_released\n"
                "BL      capt_seq_hook_set_nr\n"
                "LDR     R3, =0xC2E8\n"     
                "LDR     R0, [R3]\n"

                "B       sub_FFEABFF8\n"
    );
}

void __attribute__((naked,noinline)) sub_FFEA8E50_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,LR}\n"    
                "LDR     R4, [R0,#0xC]\n"   
                "LDR     R3, [R4,#8]\n"     
                "ORR     R3, R3, #1\n"      
                "STR     R3, [R4,#8]\n"     
                "MOV     R0, #2\n"          
                "BL      sub_FFE89DE8\n"    
                "BL      sub_FFEA9944\n"    
                "MOV     R0, R4\n"          
                "BL      sub_FFEAAA98\n"    
                "TST     R0, #1\n"          
                "MOV     R2, R4\n"          
                "MOV     R1, #1\n"          
                "BEQ     loc_FFEA8E90\n"    
                "LDMFD   SP!, {R4,LR}\n"    
                "B       sub_FFEA7618\n"    
"loc_FFEA8E90:\n"                           
                "BL      sub_FFC15B00\n"    
                "BL      sub_FFC0BE90\n"    
                "STR     R0, [R4,#0x14]\n"  
                "MOV     R0, R4\n"          
                "BL      sub_FFEABE7C\n"    
                "BL      sub_FFEAC870\n"    
                "MOV     R0, R4\n"          
                "BL      sub_FFEABF94_my\n"    
                "BL      capt_seq_hook_raw_here\n"
                "MOV     R1, #1\n"          
                "MOV     R2, R4\n"          
                "BL      sub_FFEA7618\n"    
                "BL      sub_FFEAC310\n"    
                "CMP     R0, #0\n"          
                "LDRNE   R3, [R4,#8]\n"     
                "ORRNE   R3, R3, #0x2000\n" 
                "STRNE   R3, [R4,#8]\n"     
                "LDMFD   SP!, {R4,PC}\n"    
    );
}

void __attribute__((naked,noinline)) capt_seq_task()
{
 asm volatile (
                 "STMFD   SP!, {R4,LR}\n"
                 "SUB     SP, SP, #4\n"
                 "MOV     R4, SP\n"
                 "B       loc_FFEA93D4\n"
 "loc_FFEA9268:\n"
                 "LDR     R2, [SP]\n"
                 "LDR     R3, [R2]\n"
                 "MOV     R0, R2\n"
                 "CMP     R3, #0x16\n"
                 "LDRLS   PC, [PC,R3,LSL#2]\n"
                 "B       loc_FFEA93A8\n"
                 ".long loc_FFEA92DC\n"
                 ".long loc_FFEA92E8\n"
                 ".long loc_FFEA92F0\n"
                 ".long loc_FFEA9304\n"
                 ".long loc_FFEA92FC\n"
                 ".long loc_FFEA930C\n"
                 ".long loc_FFEA9314\n"
                 ".long loc_FFEA9320\n"
                 ".long loc_FFEA9328\n"
                 ".long loc_FFEA9334\n"
                 ".long loc_FFEA933C\n"
                 ".long loc_FFEA9344\n"
                 ".long loc_FFEA934C\n"
                 ".long loc_FFEA9354\n"
                 ".long loc_FFEA935C\n"
                 ".long loc_FFEA9368\n"
                 ".long loc_FFEA9370\n"
                 ".long loc_FFEA9378\n"
                 ".long loc_FFEA9380\n"
                 ".long loc_FFEA938C\n"
                 ".long loc_FFEA9398\n"
                 ".long loc_FFEA93A0\n"
                 ".long loc_FFEA93BC\n"
 "loc_FFEA92DC:\n"
                 "BL      sub_FFEA9958\n"
                 "BL      shooting_expo_param_override\n"  // +
                 "BL      sub_FFEA710C\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA92E8:\n"
                 "BL      sub_FFEA8E50_my\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA92F0:\n"
                 "MOV     R0, #1\n"
                 "BL      sub_FFEA9B60\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA92FC:\n"
                 "BL      sub_FFEA94BC\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9304:\n"
                 "BL      sub_FFEA9924\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA930C:\n"
                 "BL      sub_FFEA9934\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9314:\n"
                 "BL      sub_FFEA9A50\n"
                 "BL      sub_FFEA710C\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9320:\n"
                 "BL      sub_FFEA8F34\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9328:\n"
                 "BL      sub_FFEA9AC4\n"
                 "BL      sub_FFEA710C\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9334:\n"
                 "BL      sub_FFEA9924\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA933C:\n"
                 "BL      sub_FFEAB1CC\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9344:\n"
                 "BL      sub_FFEAB3A0\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA934C:\n"
                 "BL      sub_FFEAB434\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9354:\n"
                 "BL      sub_FFEAB530\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA935C:\n"
                 "MOV     R0, #0\n"
                 "BL      sub_FFEAB79C\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9368:\n"
                 "BL      sub_FFEAB970\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9370:\n"
                 "BL      sub_FFEABA0C\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9378:\n"
                 "BL      sub_FFEABACC\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9380:\n"
                 "MOV     R0, #1\n"
                 "BL      sub_FFEAB79C\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA938C:\n"
                 "BL      sub_FFEA9CBC\n"
                 "BL      sub_FFEA8D74\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA9398:\n"
                 "BL      sub_FFEAB670\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA93A0:\n"
                 "BL      sub_FFEAB6CC\n"
                 "B       loc_FFEA93B8\n"
 "loc_FFEA93A8:\n"
                 "MOV     R1, #0x4C0\n"
                 "LDR     R0, =0xFFEA8BD0\n"
                 "ADD     R1, R1, #1\n"
                 "BL      sub_FFECA824\n"
 "loc_FFEA93B8:\n"
                 "LDR     R2, [SP]\n"
 "loc_FFEA93BC:\n"
                 "LDR     R3, =0x7EEC0\n"
                 "LDR     R1, [R2,#4]\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_FFEBCFCC\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FFEA8C50\n"
 "loc_FFEA93D4:\n"
                 "LDR     R3, =0x7EEC4\n"
                 "MOV     R1, R4\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R2, #0\n"
                 "BL      sub_FFEBD6E4\n"
                 "TST     R0, #1\n"
                 "BEQ     loc_FFEA9268\n"
                 "MOV     R1, #0x3F0\n"
                 "LDR     R0, =0xFFEA8BD0\n"
                 "ADD     R1, R1, #3\n"
                 "BL      sub_FFECA824\n"
                 "BL      sub_FFEBECA8\n"
                 "ADD     SP, SP, #4\n"
                 "LDMFD   SP!, {R4,PC}\n"
 );
}

/*************************************************************/
void __attribute__((naked,noinline)) exp_drv_task(){
 asm volatile(
                 "STMFD   SP!, {R4-R8,LR}\n"
                 "SUB     SP, SP, #0x20\n"
                 "ADD     R7, SP, #4\n"
                 "B       loc_ffd246dc\n"
 "loc_ffd241dc:\n"
                 "CMP     R2, #0x22\n"
                 "BNE     loc_ffd241f4\n"
                 "LDR     R0, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "B       loc_ffd24258\n"
 "loc_ffd241f4:\n"
                 "CMP     R2, #0x1D\n"
                 "BNE     loc_ffd24208\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd2409c\n"
                 "B       loc_ffd24248\n" 
 "loc_ffd24208:\n"
                 "CMP     R2, #0x1E\n"
                 "BNE     loc_ffd2421c\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd240f8\n"
                 "B       loc_ffd24248\n"
 "loc_ffd2421c:\n"
                 "SUB     R3, R2, #0x1F\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_ffd24234\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd24154\n"
                 "B       loc_ffd24248\n"
 "loc_ffd24234:\n"
                 "CMP     R2, #0x21\n"
                 "BNE     loc_ffd24264\n"
                 "BL      sub_ffcea234\n"
                 "BL      sub_ffced36c\n"
                 "BL      sub_ffcec5a4\n"
 "loc_ffd24248:\n"
                 "LDR     R3, [SP,#4]\n"
                 "LDR     R0, [R3,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x88]\n"
 "loc_ffd24258:\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd1f8d4\n"
                 "B       loc_ffd246dc\n"
 "loc_ffd24264:\n"
                 "CMP     R2, #0xD\n"
                 "MOV     R8, #1\n"
                 "BNE     loc_ffd242d4\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "ADD     R1, R1, R1,LSL#1\n"
                 "ADD     R1, R12, R1,LSL#2\n"
                 "ADD     R6, SP, #0x14\n"
                 "SUB     R1, R1, #8\n"
                 "MOV     R2, #0xC\n"
                 "MOV     R0, R6\n"
                 "BL      _memcpy\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd224ac\n"
                 "LDR     R3, [SP,#4]\n"
                 "LDR     R1, [R3,#0x7C]\n"
                 "LDR     R2, [R3,#0x8C]\n"
                 "ADD     R0, R3, #4\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x88]\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd22778\n"
                 "LDR     R3, [SP,#4]\n"
                 "ADD     R0, R3, #4\n"
                 "LDR     R1, [R3,#0x7C]\n"
                 "LDR     R2, [R3,#0x94]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x90]\n"
                 "B       loc_ffd24624\n"
 "loc_ffd242d4:\n"
                 "SUB     R3, R2, #0xE\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_ffd24390\n"
                 "ADD     R6, SP, #0x14\n"
                 "ADD     R5, SP, #8\n"
                 "MOV     R0, R12\n"
                 "MOV     R1, R6\n"
                 "MOV     R2, R5\n"
                 "BL      sub_ffd22868\n"
                 "MOV     R4, R0\n"
                 "CMP     R4, #5\n"
                 "CMPNE   R4, #1\n"
                 "BNE     loc_ffd24328\n"
                 "LDR     R12, [SP,#4]\n"
                 "MOV     R0, R5\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "MOV     R2, R4\n"
                 "LDR     R3, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "B       loc_ffd24360\n"
 "loc_ffd24328:\n"
                 "CMP     R4, #6\n"
                 "CMPNE   R4, #2\n"
                 "BNE     loc_ffd24370\n"
                 "LDR     R12, [SP,#4]\n"
                 "MOV     R0, R5\n"
                 "MOV     R1, R8\n"
                 "MOV     R2, R4\n"
                 "LDR     R3, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "MOV     R1, R6\n"
                 "LDR     R0, [SP,#4]\n"
                 "MOV     R2, R5\n"
                 "BL      sub_ffd23cfc\n"
 "loc_ffd24360:\n"
                 "MOV     R1, R4\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd24030\n"
                 "B       loc_ffd24624\n"
 "loc_ffd24370:\n"
                 "LDR     R12, [SP,#4]\n"
                 "MOV     R2, R4\n"
                 "ADD     R0, R12, #4\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "LDR     R3, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
                 "B       loc_ffd24624\n"
 "loc_ffd24390:\n"
                 "SUB     R3, R2, #0x19\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_ffd243e8\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "ADD     R1, R1, R1,LSL#1\n"
                 "ADD     R1, R12, R1,LSL#2\n"
                 "ADD     R6, SP, #0x14\n"
                 "SUB     R1, R1, #8\n"
                 "MOV     R2, #0xC\n"
                 "MOV     R0, R6\n"
                 "BL      _memcpy\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd218a0\n"
                 "LDR     R3, [SP,#4]\n"
                 "ADD     R0, R3, #4\n"
                 "LDR     R1, [R3,#0x7C]\n"
                 "LDR     R2, [R3,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x88]\n"
                 "LDR     R0, [SP,#4]\n"
                 "BL      sub_ffd21c7c\n"
                 "B       loc_ffd24624\n"
 "loc_ffd243e8:\n"
                 "ADD     R6, SP, #0x14\n"
                 "ADD     R1, R12, #4\n"
                 "MOV     R2, #0xC\n"
                 "MOV     R0, R6\n"
                 "BL      memcpy\n"
                 "LDR     R12, [SP,#4]\n"
                 "LDR     R3, [R12]\n"
                 "MOV     R2, R12\n"
                 "CMP     R3, #0x1C\n"
                 "LDRLS   PC, [PC,R3,LSL#2]\n"
                 "B       loc_ffd24610\n"
                 ".long loc_ffd24488\n"
                 ".long loc_ffd24494\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd24488\n"
                 ".long loc_ffd24494\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd244a0\n"
                 ".long loc_ffd244c4\n"
                 ".long loc_ffd244c4\n"
                 ".long loc_ffd245e4\n"
                 ".long loc_ffd245f0\n"
                 ".long loc_ffd24600\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd244ac\n"
                 ".long loc_ffd244b8\n"
                 ".long loc_ffd244d4\n"
                 ".long loc_ffd244e0\n"
                 ".long loc_ffd24518\n"
                 ".long loc_ffd24550\n"
                 ".long loc_ffd24588\n"
                 ".long loc_ffd245c0\n"
                 ".long loc_ffd245c0\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd24610\n"
                 ".long loc_ffd245cc\n"
                 ".long loc_ffd245d8\n"
 "loc_ffd24488:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20278\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24494:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd2051c\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244a0:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20790\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244ac:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20a8c\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244b8:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20cf4\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244c4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd20ef4_my\n"  //---------->                 
                 "MOV     R8, #0\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd244d4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd21054\n"
                 "B       loc_ffd2460c\n"
                 
                 
 "loc_ffd244e0:\n"
                 "LDRH    R1, [R2,#4]\n"
                 "LDR     R3, =0x2AFE0\n"
                 "STRH    R1, [SP,#0x14]\n"
                 "LDRH    R1, [R3,#6]\n"
                 "STRH    R1, [SP,#0x1A]\n"
                 "LDRH    R1, [R3,#2]\n"
                 "STRH    R1, [SP,#0x16]\n"
                 "LDRH    R3, [R3,#4]\n"
                 "STRH    R3, [SP,#0x18]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#0xC]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "BL      sub_ffd2134c\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24518:\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#4]\n"
                 "LDR     R3, =0x2AFE0\n"
                 "STRH    R2, [SP,#0x14]\n"
                 "LDRH    R2, [R3,#8]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "LDRH    R1, [R3,#2]\n"
                 "STRH    R1, [SP,#0x16]\n"
                 "LDRH    R2, [R3,#4]\n"
                 "STRH    R2, [SP,#0x18]\n"
                 "LDRH    R3, [R3,#6]\n"
                 "STRH    R3, [SP,#0x1A]\n"
                 "BL      sub_ffd21474\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24550:\n"
                 "LDR     R3, =0x2AFE0\n"
                 "LDRH    R1, [R3]\n"
                 "STRH    R1, [SP,#0x14]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#6]\n"
                 "STRH    R2, [SP,#0x16]\n"
                 "LDRH    R2, [R3,#8]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "LDRH    R1, [R3,#4]\n"
                 "STRH    R1, [SP,#0x18]\n"
                 "LDRH    R3, [R3,#6]\n"
                 "STRH    R3, [SP,#0x1A]\n"
                 "BL      sub_ffd21538\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24588:\n"
                 "LDR     R3, =0x2AFE0\n"
                 "LDRH    R1, [R3,#6]\n"
                 "STRH    R1, [SP,#0x1A]\n"
                 "LDRH    R1, [R3]\n"
                 "STRH    R1, [SP,#0x14]\n"
                 "LDRH    R1, [R3,#2]\n"
                 "STRH    R1, [SP,#0x16]\n"
                 "LDRH    R3, [R3,#4]\n"
                 "STRH    R3, [SP,#0x18]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#0xC]\n"
                 "STRH    R2, [SP,#0x1C]\n"
                 "BL      sub_ffd215f0\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245c0:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd216a0\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245cc:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd21dc8\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245d8:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd21fc4\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245e4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_ffd22180\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd245f0:\n"
                 "MOV     R0, R2\n"
                 "MOV     R1, #0\n"
                 "BL      sub_ffd22368\n"
                 "B       loc_ffd2460c\n"
 "loc_ffd24600:\n"
                 "MOV     R0, R2\n"
                 "MOV     R1, #1\n"
                 "BL      sub_ffd22368\n"
 "loc_ffd2460c:\n"
                 "LDR     R12, [SP,#4]\n"
 "loc_ffd24610:\n"
                 "ADD     R0, R12, #4\n"
                 "LDR     R1, [R12,#0x7C]\n"
                 "LDR     R2, [R12,#0x8C]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x88]\n"
 "loc_ffd24624:\n"
                 "CMP     R8, #1\n"
                 "BNE     loc_ffd2464c\n"
                 "LDR     R1, [SP,#4]\n"
                 "LDR     R3, [R1,#0x7C]\n"
                 "ADD     R3, R3, R3,LSL#1\n"
                 "ADD     R1, R1, R3,LSL#2\n"
                 "MOV     R0, R6\n"
                 "SUB     R1, R1, #8\n"
                 "BL      sub_ffd1ff30\n"
                 "B       loc_ffd246c8\n"
 "loc_ffd2464c:\n"
                 "LDR    R3, [SP,#4]\n"
                 "LDR    R2, [R3]\n"
                 "CMP    R2, #9\n"
                 "BNE    loc_ffd24694\n"
                 "MOV    R4, #0\n"
                 "MOV    R1, #1\n"
                 "MOV    R2, R1\n"
                 "MOV    R3, R1\n"
                 "MOV    R0, R4\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd1fe74\n"
                 "MOV    R1, #1\n"
                 "MOV    R0, R4\n"
                 "MOV    R2, R1\n"
                 "MOV    R3, R1\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd200cc\n"
                 "B      loc_ffd246c8\n"
 "loc_ffd24694:\n"
                 "MOV    R4, #1\n"
                 "MOV    R0, R4\n"
                 "MOV    R1, R4\n"
                 "MOV    R2, R4\n"
                 "MOV    R3, R4\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd1fe74\n"
                 "MOV    R0, R4\n"
                 "MOV    R1, R0\n"
                 "MOV    R2, R0\n"
                 "MOV    R3, R0\n"
                 "STR    R4, [SP]\n"
                 "BL     sub_ffd200cc\n"

 "loc_ffd246c8:\n"
                 "LDR    R2, =0x2B030\n"
                 "MOV    R3, #0\n"
                 "LDR    R0, [SP,#4]\n"
                 "STR    R3, [R2]\n"
                 "BL     sub_ffd1f8d4\n"

 "loc_ffd246dc:\n"
                 "LDR     R3, =0x2AFD4\n"
                 "MOV     R2, #0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, R7\n"
                 "BL      sub_ffebd6e4\n"
                 "LDR     R12, [SP,#4]\n"
                 "LDR     R2, [R12]\n"
                 "CMP     R2, #0x23\n"
                 "BNE     loc_ffd241dc\n"
                 "MOV     R0, R12\n"
                 "BL      sub_ffd1f8d4\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R1, #1\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_ffebcfcc\n"
                 "BL      sub_ffebeca8\n" // ExitTask
                 "ADD     SP, SP, #0x20\n"
                 "LDMFD   SP!, {R4-R8,PC}\n"
 );
}

void __attribute__((naked,noinline)) sub_ffd20ef4_my(){
 asm volatile(
                 "STMFD   SP!, {R4-R6,LR}\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R4, R0\n"
                 "MOV     R1, #0x3E\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_ffebd168\n"
                 "MOV     R1, #0\n"
                 "LDRSH   R0, [R4,#4]\n"
                 "BL      sub_ffd1fa08\n"
                 "MOV     R6, R0\n"
                 "LDRSH   R0, [R4,#6]\n"
                 "BL      sub_ffd1fbb4\n"
                 "LDRSH   R0, [R4,#8]\n"
                 "BL      sub_ffd1fc50\n"
                 "LDRSH   R0, [R4,#0xA]\n"
                 "BL      sub_ffd1fcec\n"
                 "LDRSH   R0, [R4,#0xC]\n"
                 "BL      sub_ffd1fd88\n"
                 "LDR     R3, [R4]\n"
                 "CMP     R3, #9\n"
                 "MOV     R5, R0\n"
                 "MOVEQ   R5, #0\n"
                 "MOVEQ   R6, R5\n"
                 "CMP     R6, #1\n"
                 "BNE     loc_ffd20f78\n"
                 "MOV     R2, #2\n"
                 "LDRSH   R0, [R4,#4]\n"
                 "LDR     R1, =0xFFD1F928\n"
                 "BL      sub_ffe7827c\n"
                 "LDR     R2, =0x2B020\n"
                 "MOV     R3, #0\n"
                 "STR     R3, [R2]\n"
                 "B       loc_ffd20f7c\n"
 "loc_ffd20f78:\n"
                 "BL      sub_ffd1fe24\n"
 "loc_ffd20f7c:\n"
                 "STRH    R0, [R4,#4]\n"
                 "CMP     R5, #1\n"
                 "BNE     loc_ffd20f9c\n"
                 "LDRSH   R0, [R4,#0xC]\n"
                 "LDR     R1, =0xFFD1F9EC\n"
                 "MOV     R2, #0x20\n"
                 "BL      sub_ffd20218\n"
                 "B       loc_ffd20fa0\n"
 "loc_ffd20f9c:\n"
                 "BL      sub_ffd1fe64\n"
 "loc_ffd20fa0:\n"
                 "STRH    R0, [R4,#0xC]\n"
                 "LDRSH   R0, [R4,#6]\n"
                 "BL      sub_ffce9eb0_my\n"  // ------------->
                 "LDRSH   R0, [R4,#8]\n"
                 "MOV     R1, #1\n"
                 "BL      sub_ffcec164\n"
                 "ADD     R0, R4, #8\n"
                 "MOV     R1, #0\n"
                 "BL      sub_ffcec224\n"
                 "LDRSH   R0, [R4,#0xE]\n"
                 "BL      sub_ffd0e5d4\n"
                 "CMP     R6, #1\n"
                 "BNE     loc_ffd21004\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R2, #0xBB0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, #2\n"
                 "ADD     R2, R2, #8\n"
                 "BL      sub_ffebcf48\n"
                 "TST     R0, #1\n"
                 "BEQ     loc_ffd21004\n"
                 "MOV     R1, #0x4a0\n"
                 "LDR     R0, =0xFFD1F880\n"
                 "ADD     R1, R1, #3\n"
                 "BL      sub_ffeca824\n"
 "loc_ffd21004:\n"
                 "CMP     R5, #1\n"
                 "LDMNEFD SP!, {R4-R6,PC}\n"
                 "LDR     R3, =0x2AFD0\n"
                 "MOV     R2, #0xBB0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, #0x20\n"
                 "ADD     R2, R2, #8\n"
                 "BL      sub_ffebcfbc\n"
                 "TST     R0, #1\n"
                 "LDMEQFD SP!, {R4-R6,PC}\n"
                 "MOV     R1, #0x4A0\n"
                 "LDR     R0, =0xFFD1F880\n"
                 "ADD     R1, R1, #8\n"
                 "LDMFD   SP!, {R4-R6,LR}\n"
                 "B       sub_ffeca824\n"
 );
}

void __attribute__((naked,noinline)) sub_ffce9eb0_my(){
 asm volatile(
                 "STMFD   SP!, {R4,LR}\n"
                 "LDR     R3, =0x59FC\n"
                 "LDR     R2, [R3]\n"
                 "MOV     R1, #0x168\n"
                 "MOV     R3, R0,LSL#16\n"
                 "CMP     R2, #1\n"
                 "ADD     R1, R1, #3\n"
                 "LDR     R0, =0xFFCE96CC\n"
                 "MOV     R4, R3,ASR#16\n"
                 "BEQ     loc_FFCE9EDC\n"
                 "BL      sub_ffeca824\n"
 "loc_FFCE9EDC:\n"
                 "MOV     R1, #0x170\n"
                 "CMN     R4, #0xC00\n"
                 "LDR     R3, =0x11B4E\n"
                 "LDR     R0, =0xFFCE96CC\n"
                 "ADD     R1, R1, #1\n"
                 "LDREQSH R4, [R3]\n"
                 "LDRNE   R3, =0x11B4E\n"
                 "CMN     R4, #0xC00\n"
                 "STRH    R4, [R3]\n"
                 "BNE     loc_FFCE9F08\n"
                 "BL      sub_ffeca824\n"
 "loc_FFCE9F08:\n"
                 "MOV     R0, R4\n"
                 "BL      apex2us\n"  //---------->
                 "MOV     R4, R0\n"
                 "BL      sub_FFD764E0\n"
                 "MOV     R0, R4\n"
                 "BL      sub_ffd8d97c\n"
                 "MOV     R1, #0x174\n"
                 "TST     R0, #1\n"
                 "ADD     R1, R1, #2\n"
                 "LDR     R0, =0xFFCE96CC\n"
                 "LDMEQFD SP!, {R4,PC}\n"
                 "LDMFD   SP!, {R4,LR}\n"
                 "B       sub_ffeca824\n"
 );
}
